﻿using Sustainalytics.Alerts.AlertsEngine;
using Sustainalytics.Entities;
using System;
using System.ServiceProcess;

namespace Sustainalytics.Alerts.Service
{
    static class Program
    {

       
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            if (Environment.UserInteractive)
            {
                // start as console app
                ConsoleStart();
            }
            else
            {
                // start as windows service
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[] 
                { 
                    new AlertsService() 
                };
                ServiceBase.Run(ServicesToRun);
            }
        }

        public static void ConsoleStart()
        {


            try
            {
                new AlertsHelper().Start();

                Console.WriteLine("Alerts started");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadKey();
            }
        }
    }
}
